#include "logfiltermodel.h"
#include "logmodel.h"


LogFilterModel::LogFilterModel(QObject *parent) :
    QSortFilterProxyModel(parent)
{
}
bool LogFilterModel::filterAcceptsRow(int sourceRow,
                      const QModelIndex &sourceParent) const
{
    //如果是所有,则直接返回真,即全部行都有效
    QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
    if(!m_type.isEmpty())
    {
        QString type = sourceModel()->data(index,LogModel::TypeRole).toString();
        return m_type == type;
    }
    return true;
}

void LogFilterModel::setType(const QString &type)
{
    m_type = type;
}
